package com.hspedu.exception_.throws_;

/**
 * @Author Stringzhua
 * @Date 2024/3/8 12:54
 * description:阅读代码,写出结果
 *
 * result:
 * 进入方法A
 * 用A方法的finally
 * 制造异常
 * 进入方法B
 * 调用B方法的finally
 */
public class ThrowException {
    public static void main(String[] args) {
        try {
            ReturnExceptionDemo.methodA();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        ReturnExceptionDemo.methodB();
    }
}

class ReturnExceptionDemo{
    static void methodA(){
        try {
            System.out.println("进入方法A");
            throw new RuntimeException("制造异常");
        } finally {
            System.out.println("用A方法的finally");
        }
    }

    static void methodB(){
        try {
            System.out.println("进入方法B");
            return;
        } finally {
            System.out.println("调用B方法的finally");
        }
    }
}
